package com.sztx.pay.center.core.service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;

import com.sztx.se.dataaccess.mysql.source.DataSourceSwitcher;

@Ignore
@RunWith(SpringJUnit4ClassRunner.class)
//@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)  
//@Transactional
@ContextConfiguration(locations = { "classpath*:spring-config-test.xml" })
//@ContextConfiguration(locations = { "classpath*:spring-mysql.xml" })
@WebAppConfiguration
public class BaseService {
	private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
//		DataSourceSwitcher.setDataSourceTypeInContext("tradeCenterMaster");
		
	}
	
	 public String getOrder() {
	      Random random = new Random();
	      int r = random.nextInt(1000)%1000 + 1;        
	      return sdf.format(new Date()) + String.format("%04d", r);
	}

	@Test
	public void testGenOrder(){	
		for (int i = 0; i < 1000; i++) {
			System.out.println(getOrder());
		}
	}
}
